package top.syfy.api.jdcloud.joke.controller;

import com.fasterxml.jackson.core.JsonProcessingException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import top.syfy.api.jdcloud.joke.entity.JokeDO;
import top.syfy.api.jdcloud.joke.entity.dto.PageDTO;
import top.syfy.api.jdcloud.joke.response.ContentReturnType;
import top.syfy.api.jdcloud.joke.service.JokeService;

/**
 * 获取笑话
 *
 * @author awg
 * @date 2020/10/30 星期五
 */
@RestController
@RequestMapping(value = "/joke")
public class JokeController {

    @Autowired
    private JokeService<PageDTO<JokeDO>> jokeServiceImpl;

    /**
     * 获取指定对象的集合
     *
     * @param p 包含必要请求参数的数据传输对象
     * @return 指定对象的集合
     */
    @PostMapping(value = "/list")
    public ContentReturnType listJoke(@RequestBody PageDTO<JokeDO> p) throws JsonProcessingException {
        return jokeServiceImpl.listEntityPage(p);
    }
}
